home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Format CD 38
/
Amiga Format CD38 (1999-03-15)(Future Publishing)(GB)(Track 1 of 3)[!][issue 1999-04].iso
/
-in_the_mag-
/
reader_requests
/
dice_v3.15
/
lib
/
fd
/
close.c
< prev
next >
Wrap
C/C++ Source or Header
|
1999-01-26
|
924b
|
57 lines
/*
* CLOSE.C
*
* (c)Copyright 1992-1997 Obvious Implementations Corp. Redistribution and
* use is allowed under the terms of the DICE-LICENSE FILE,
* DICE-LICENSE.TXT.
*/
#include <clib/dos_protos.h>
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <ioctl.h>
#include <errno.h>
#include <lib/misc.h>
int __InUnixFork;
void
__closeall(void)
{
short fd;
for (fd = 0; fd < _IoFDLimit; ++fd)
close(fd);
}
int
close(fd)
int fd;
{
_IOFDS *d;
int r = -1;
if (d = __getfh(fd)) {
if (__InUnixFork)
return(0);
if (d->fd_FileName)
free(d->fd_FileName);
if (d->fd_Exec) { /* special */
r = (*d->fd_Exec)(d->fd_Fh, IOC_CLOSE, NULL, NULL);
} else {
r = 0;
if ((d->fd_Flags & O_NOCLOSE) == 0)
Close(d->fd_Fh);
}
d->fd_Flags = 0;
d->fd_Exec = NULL;
d->fd_Fh = NULL;
d->fd_FileName = NULL;
}
return(r);
}